package com.example.foobar.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.example.foobar.entity.DaQrcodeNewCommerCount;
import com.example.foobar.mapper.DaQrcodeNewCommerCountMapper;
import com.example.foobar.dao.service.DaQrcodeNewCommerCountDaoService;
import com.example.foobar.param.DaQrcodeNewCommerCountPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

/**
 * 新增用户数记录 服务实现类
 *
 * @author 郑英奔
 * @since 2021-07-15
 */
@Slf4j
@Service
public class DaQrcodeNewCommerCountDaoServiceImpl extends BaseServiceImpl<DaQrcodeNewCommerCountMapper, DaQrcodeNewCommerCount> implements DaQrcodeNewCommerCountDaoService {

    @Autowired
    private DaQrcodeNewCommerCountMapper daQrcodeNewCommerCountMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveDaQrcodeNewCommerCount(DaQrcodeNewCommerCount daQrcodeNewCommerCount)  {
        return super.save(daQrcodeNewCommerCount);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateDaQrcodeNewCommerCount(DaQrcodeNewCommerCount daQrcodeNewCommerCount)  {
        return super.updateById(daQrcodeNewCommerCount);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteDaQrcodeNewCommerCount(Long id)  {
        return super.removeById(id);
    }

    @Override
    public List<DaQrcodeNewCommerCount> getDaNewCommerByUniacidAndDate(String sceneId, Date baseDate) {
        Wrapper<DaQrcodeNewCommerCount> wrapper = new LambdaQueryWrapper<>(DaQrcodeNewCommerCount.class).eq(DaQrcodeNewCommerCount::getSceneId, sceneId).eq(DaQrcodeNewCommerCount::getDate,baseDate);
        return daQrcodeNewCommerCountMapper.selectList(wrapper);
    }


}
